import Vue from 'vue'
import 'babel-polyfill'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/global.css'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import _isMobile from './utils/isMobile'
import i18n from './i18n/i18n'
import $api from './utils/reset'
import configUrl from './baseconfig.js'
import formCreate from '@form-create/element-ui'
import VueCookies from "vue-cookies";

if (!_isMobile) {
  require('./styles/mobile.styl');
} else {
  require('./styles/pc.styl');
}
 Vue.use(VueCookies);
Vue.config.productionTip = false
Vue.prototype.$api = $api
Vue.prototype.uploadUrl= configUrl.uploadUrl;
router.beforeEach((to,from,next)=>{
  const isLogin = localStorage.getItem('zzr_user')?true:false;
  if(to.matched.some(record => record.meta.requireAuth)){ //判断是否需要登录权限
    //var userInfo = localStorage.getItem('accessToken')
    if(to.path=='/'){
      next()
    }else{
      isLogin?next():next('/')
    }
  }
  else{
    next()
  }
})
Vue.use(ElementUI)
Vue.use(formCreate)
const vue = new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')


export default vue
